package com.itheima.service.mongo.impl;

import com.itheima.domain.mongo.FocusUser;
import com.itheima.service.mongo.FocusUserService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;


/**
 * @Author 请不要叫我高司令
 * @Date 2022/3/23 19:31
 * @Version 1.0
 */

@DubboService
public class FocusUserServiceImpl implements FocusUserService {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void saveFocusUser(FocusUser focusUser) {

        mongoTemplate.save(focusUser);


    }

    @Override
    public void removeFocusUser(Long userId, Long focusUserId) {

        Query query = new Query(
                Criteria.where("userId").is(userId).and("focusUserId").is(focusUserId)
        );

        mongoTemplate.remove(query, FocusUser.class);



    }


}
